/*
 * @Author: anxia.ack anchenkai@come-future.com
 * @Date: 2025-04-05 16:24:36
 * @LastEditors: anxia.ack anchenkai@come-future.com
 * @LastEditTime: 2025-04-20 20:32:00
 * @FilePath: /free-learning/src/api/course/index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import request from "@/utils/request";
import type { CourseInfo, CourseListParams, CourseListVO } from "./type";

const COURSE_BASE_URL = "/api/v1/course";

export const getCourseList = (params: CourseListParams) => {
  return request<any, MyPageResult<CourseListVO[]>>({
    url: `${COURSE_BASE_URL}/page`,
    method: "post",
    data: params,
  });
};

export const addCourse = (params: CourseInfo) => {
  return request<boolean>({
    url: `${COURSE_BASE_URL}/add`,
    method: "post",
    data: params,
  });
};

export const updateCourse = (params: CourseInfo) => {
  return request<boolean>({
    url: `${COURSE_BASE_URL}/update`,
    method: "post",
    data: params,
  });
};

export const deleteCourse = (id: number) => {
  return request<boolean>({
    url: `${COURSE_BASE_URL}/delete/${id}`,
    method: "delete",
  });
};

export const postSendCourse = (id: number) => {
  return request<boolean>({
    url: `${COURSE_BASE_URL}/update/status/${id}`,
    method: "post",
  });
};
export const postRecommendCourse = (id: number) => {
  return request<boolean>({
    url: `${COURSE_BASE_URL}/recommend/${id}`,
    method: "post",
  });
};

export const getCourseListByConsultantId = (
  params?: Partial<CourseInfo>
): Promise<CourseInfo[]> => {
  return request({
    url: `${COURSE_BASE_URL}/allPublish/listByConsultantId`,
    method: "post",
    data: params,
  });
};
